package day0722API;

import dayOOP0714.Stud;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class Test3 {
    public static void main(String[] args) {
        ArrayList list2=new ArrayList();
        list2.add(new Stud(1001,"张三",'w',1.7));
        list2.add(new Stud(1002,"李四",'F',1.8));
        list2.add(new Stud(1003,"王五",'w',1.9));
        list2.add(new Stud(1004,"赵六",'F',1.7));
        list2.add(new Stud(1005,"乔峰",'w',1.6));

        //比较器
        Comparator<Stud>  c=new Comparator<Stud>() {
            public int compare(Stud  o1, Stud o2) {
                return (int)(o1.getHeight()*10-o2.getHeight()*10);
            }
        };


/*
        Comparator  c=(o1,o2) -> {
            Stud oo1=(Stud)o1;
            Stud oo2=(Stud)o2;
            return (int)(oo2.getHeight()*10-oo1.getHeight()*10);
        };*/

        Comparator<Stud>  c2=(o1,o2) -> (int)(o1.getHeight()*10-o2.getHeight()*10);

        Collections.sort(list2, c);
        System.out.println(list2);
    }
}